home *** CD-ROM | disk | FTP | other *** search
/ Garden Fax: Fruits, Vegetables & Herbs / Garden Fax - Fruits, Vegetables & Herbs (1991)(CDTV Publishing)[!].iso / system / basicdemos / speech (.txt) < prev    next >
AmigaBASIC Source Code  |  1978-01-06  |  2KB  |  98 lines

  1. REM --- Speech Demo Program
  2. GOSUB InitSpeech
  3. LOCATE 1,1
  4. PRINT "Use Mouse to change control settings."
  5. PRINT "Please type what you want me to say, followed by the Return"
  6. PRINT "key, or just press Return to repeat the last message."
  7. COLOR 0,1
  8. WHILE 1
  9.   LOCATE 4,1
  10.   PRINT ">";SPACE$(80)
  11.   LOCATE 4,3
  12.   k$=""
  13.   msg$=""
  14.   REM -- This loop builds msg$, we don't just do a LINE INPUT is to
  15.   REM -- allow Mouse Interrupts 
  16.   WHILE k$<>CHR$(13)
  17.     k$=INKEY$
  18.     IF k$<>"" THEN
  19.       IF k$=CHR$(8) THEN 'backspace
  20.         LenMSG=LEN(msg$)
  21.         IF LenMSG>0 THEN
  22.           msg$=LEFT$(msg$,LenMSG-1)
  23.           PRINT k$;
  24.         END IF
  25.       ELSE
  26.         msg$=msg$+k$
  27.         PRINT k$;
  28.       END IF
  29.     END IF
  30.   WEND
  31.   IF msg$=CHR$(13) THEN
  32.     msg$=lastMsg$
  33.     LOCATE 4,3
  34.     PRINT msg$
  35.   END IF
  36.   lastMsg$=msg$
  37.   SAY TRANSLATE$(msg$),current%
  38. WEND
  39.  
  40. DrawControls:
  41.   FOR i=0 TO 5
  42.     LOCATE 2*i+6,1
  43.     PRINT "    ";nam$(i);
  44.     WHILE POS(0)<18: PRINT ".";: WEND
  45.     x1(i)=WINDOW(4)+10
  46.     y1(i)=WINDOW(5)-8
  47.     x2(i)=WINDOW(4)+100
  48.     y2(i)=WINDOW(5)
  49.     GOSUB DrawControl
  50.     NEXT i
  51.   RETURN
  52.   
  53. REM --- Draw's control box for control
  54. DrawControl:
  55.   LINE (x1(i),y1(i))-(x2(i),y2(i)),3,bf
  56.   x=(current%(i)-min(i))/(max(i)-min(i))
  57.   x=x1(i)+x*(x2(i)-x1(i))
  58.   LINE (x-2,y1(i))-(x+2,y2(i)),2,bf
  59.   RETURN
  60.   
  61. HandleMouse:
  62.   WHILE MOUSE(0)<>0
  63.     mouseX=MOUSE(1)
  64.     mouseY=MOUSE(2)
  65.     FOR i=0 TO 5
  66.       IF mouseX>x1(i) AND mouseX<x2(i) THEN
  67.         IF mouseY>y1(i) AND mouseY<y2(i) THEN
  68.           v=(mouseX-x1(i))/(x2(i)-x1(i))
  69.           current%(i)=min(i)+v*(max(i)-min(i))
  70.           GOSUB DrawControl
  71.         END IF
  72.       END IF
  73.     NEXT i
  74.   WEND
  75.   RETURN
  76.   
  77. InitSpeech:
  78.   FOR i=0 TO 5
  79.     READ nam$(i),min(i),max(i),current%(i)
  80.   NEXT i
  81.   SAY TRANSLATE$("Please"),current%
  82.   GOSUB DrawControls
  83.   ON MOUSE GOSUB HandleMouse
  84.   MOUSE ON
  85.   SAY TRANSLATE$("type what you want me to say"),current%
  86.   RETURN  
  87.   
  88. DATA "Pitch",65,320,105
  89. DATA "Inflection",0,1,0
  90. DATA "Rate",40,400,144
  91. DATA "Voice",0,1,0
  92. DATA "Tune",5000,28000,20590
  93. DATA "Volume",0,64,63
  94.  
  95.  
  96.   
  97.  
  98.